//A.1. Crime map

*ssc install spmap
*ssc install shp2dta
*ssc install mif2dta

clear all
clear matrix
set more off

// Locate maps Files
cd "~/Dropbox/Replication_MVC/Datasets/Maps"

// Load Ex-combatnat data
use "~/Dropbox/Replication_MVC/Datasets/datasets_analysis/panel_excombatientes.dta", clear 

// Clean origmuncaptura
replace origmuncaptura = "." if inlist(origmuncaptura, "Amenazas", "Aplica>", "Armadas", "Asonada", "Dato", "Estafa", "Homicidio")
replace origmuncaptura = "." if inlist(origmuncaptura, "Hurto", "Otros", "PROTEGIDA", "Personales", "Registra>", "Secuestro")
replace origmuncaptura = "." if inlist(origmuncaptura, "Terrorismo", "delinquir", "estupefacientes", "municiones", "Personales")

// Prox captures by mun
keep if year == 2016
collapse NdeCapturasCrucePONAL, by (origmuncaptura)

// Rename vars
destring origmuncaptura, replace 
rename origmuncaptura MPIOS
rename NdeCapturasCrucePONAL average_captures

// Map file
merge 1:1 MPIOS using "colombia_municipios_mapa.dta"

// Non Excombatant/crime municipalitites 
replace average_captures = 0 if average_captures == .

// Plot 
spmap average_captures using colombia_coord, id(id) fcolor(Purples) ///
    clmethod(custom) clbreaks(0 0.01 1 1.5 3 9) ///
    legtitle("Average number of Detentions during 2003-2016") ///
    title("Average of Criminal Activity among Ex-Combatants", size(*0.8))



